package com.ziyun.erp.web.modules.storeMaterialInDetail.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.storeMaterialInDetail.entity.StoreMaterialInDetailEntity;
import com.ziyun.erp.modules.storeMaterialInDetail.service.StoreMaterialInDetailService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 门店入库明细表
 *
 * @author xueqz
 * @email 
 * @date 2018-12-13 15:14:15
 */
@RestController
@RequestMapping("storeMaterialInDetail/storematerialindetail")
public class StoreMaterialInDetailController {
    @Autowired
    private StoreMaterialInDetailService storeMaterialInDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("storeMaterialInDetail:storematerialindetail:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = storeMaterialInDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{detailId}")
    @RequiresPermissions("storeMaterialInDetail:storematerialindetail:info")
    public R info(@PathVariable("detailId") Integer detailId){
        StoreMaterialInDetailEntity storeMaterialInDetail = storeMaterialInDetailService.selectById(detailId);

        return R.ok().put("storeMaterialInDetail", storeMaterialInDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("storeMaterialInDetail:storematerialindetail:save")
    public R save(@RequestBody StoreMaterialInDetailEntity storeMaterialInDetail){
        storeMaterialInDetailService.insert(storeMaterialInDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("storeMaterialInDetail:storematerialindetail:update")
    public R update(@RequestBody StoreMaterialInDetailEntity storeMaterialInDetail){
        ValidatorUtils.validateEntity(storeMaterialInDetail);
        storeMaterialInDetailService.updateAllColumnById(storeMaterialInDetail);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("storeMaterialInDetail:storematerialindetail:delete")
    public R delete(@RequestBody Integer[] detailIds){
        storeMaterialInDetailService.deleteBatchIds(Arrays.asList(detailIds));

        return R.ok();
    }

}
